package com.codegen.service.impl;

import com.codegen.dao.TableGenParamDao;
import com.codegen.entity.TableGenParam;
import com.codegen.entity.TableVo;
import com.codegen.service.TableGenParamService;
import com.codegen.utils.PageUtils;
import com.codegen.utils.Query;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class TableGenParamServiceImpl implements TableGenParamService {

    @Autowired
    private TableGenParamDao tableGenParamDao;

    @Override
    public int addProject(TableGenParam tableGenParam) {

        return tableGenParamDao.addProject(tableGenParam);
    }

    @Override
    public int editProject(TableGenParam tableGenParam) {

        return tableGenParamDao.editProject(tableGenParam);
    }

    @Override
    public List<TableGenParam> selectAll() {

        return tableGenParamDao.selectAll();
    }

    @Override
    public TableGenParam selectOneByProjectId(Integer projectId) {

        return tableGenParamDao.selectOneByProjectId(projectId);
    }

    @Override
    public PageUtils queryList(Query query) {
        Page<?> page = PageHelper.startPage(query.getPage(), query.getLimit());
        List<TableGenParam> list = tableGenParamDao.queryList(query);
        return new PageUtils(list, (int) page.getTotal(), query.getLimit(), query.getPage());
    }
}
